import { defineStore } from "pinia";
import { store } from "./index";

export const FormOptions = defineStore("FormOptions", {
    state: () => {
        return {
            OrderId: 1,
            param: {},
            view: {
                Type: "RootForm",
                options: { labelCol: { style: { width: "150px" } } },
                slots: {
                    default: [],
                },
            },
        };
    },
    actions: {
        GetOptions(Key) {
            return this.param[Key];
        },
        GetOrderId() {
            return this.OrderId++;
        },
        SetConfig(data) {
            this.param = data.param;
            this.view = data.view;
        },
        GetConfig() {
            var data = JSON.parse(JSON.stringify(this));
            delete data.$id;
            delete data._isOptionsAPI;
            return data;
        },
    },
});
export function GetFormOptions() {
    return FormOptions(store);
}
